home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Tcl / Modes / igorMode.tcl < prev    next >
Encoding:
Text File  |  2000-12-07  |  4.0 KB  |  149 lines

  1. # nowrap
  2.  
  3. alpha::mode Igor 1.02 igorMenu { *.igor } {igorMenu electricTab} {
  4.     addMenu igorMenu "•284"
  5. } help {
  6.     Igor Mode supplies a menu for easy switching between Igor and Alpha,
  7.     and provides keyword coloring.  (Versions of Igor before v4 did not
  8.     support keyword coloring.)
  9.  
  10.     Click on this "Igor Example.igor" link for an example syntax file.
  11. }
  12.  
  13.  
  14. proc igorMenu {} {}
  15.  
  16. newPref sig igorSig IGR0
  17.  
  18. Menu -n $igorMenu -p igorMenuProc {
  19.     "/S<U<OswitchToIgor"
  20.     "(-"
  21.     "/K<U<OopenFileInIgor"
  22.     "/K<U<O<BswitchFileToIgor"
  23. }
  24.  
  25. proc igorMenuProc {menu item} {
  26.     global igorSig
  27.     switch -- $item {
  28.     switchToIgor {app::launchFore $igorSig}
  29.     openFileInIgor {
  30.         openAndSendFile $igorSig
  31.     }
  32.     switchFileToIgor {
  33.         openAndSendFile $igorSig
  34.         killWindow
  35.     }
  36.     }
  37. }
  38.  
  39.  
  40. set Igor::commentCharacters(General) "// "
  41. set Igor::commentCharacters(Paragraph) [list "// " "// " "// "]
  42.  
  43. newPref v leftFillColumn {3} Igor
  44. newPref v prefixString {//} Igor
  45. newPref f wordWrap {0} Igor
  46. newPref v funcExpr {^[ \t]*([pP]roc.+$|[mM]acro.+$|[fF]unction.+$)} Igor
  47. if {[info tclversion] < 8.0} {
  48.     newPref v parseExpr {\b([_:\w]+)\s*\(} Igor
  49. } else {
  50.     newPref v parseExpr {\m([_:\w]+)\s*\(} Igor
  51. }
  52. newPref v wordBreak {[_\w]+} Igor
  53. newPref v wordBreakPreface {[^_\w]} Igor
  54. newPref f autoMark 0 Igor
  55. newPref color stringColor green Igor
  56. newPref color commentColor red Igor
  57. newPref color funcColor yellow Igor
  58. newPref color keywordColor blue Igor
  59.  
  60. set igorCommentRegexp    {(//|[^%]\|)}
  61. set igorPreRegexp    "^\#\[\t \]*\[a-z\]*"
  62. set igorKeyWords {
  63.     break for if endif do while continue
  64.     return else end variable string wave NVAR SVAR
  65.     function proc macro
  66. }
  67.  
  68. regModeKeywords -e {//} -c red -f yellow -k blue -s green Igor $igorKeyWords
  69.  
  70. unset igorKeyWords
  71.  
  72. proc Igor::MarkFile {} {
  73.     global IgormodeVars
  74.     set pos [minPos]
  75.     
  76.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 $IgormodeVars(funcExpr) $pos} res]} {
  77.     set start [lindex $res 0]
  78.     set end [pos::math [lindex $res 1] + 1]
  79.     set text [getText $start $end]
  80.     set inds($text) [list $start [pos::math $start + [string length $text]]]
  81.     set pos $end
  82.     }
  83.     
  84.     set pos [minPos]
  85.     set markExpr {(^[ \t]*[Mm]enu.*$|===[^=]+===\s*$)}
  86.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 -- "$markExpr" $pos} res]} {
  87.     set start [lindex $res 0]
  88.     set end [pos::math [lindex $res 1] - 1]
  89.     set text [string trimright [getText $start $end] ]
  90.     set inds($text) [list $start [pos::math $start + [string length $text]]]
  91.     set pos $end
  92.     }
  93.     if {[info exists inds]} {
  94.     foreach f [array names inds] {
  95.         set res $inds($f)
  96.         setNamedMark $f [lineStart [lindex $res 0]] [lindex $res 0] [lindex $res 1]
  97.     }
  98.     }
  99.     namedMarkProc {namedMarks} {sortByPosition}
  100. }
  101.  
  102. ## 
  103.  # -------------------------------------------------------------------------
  104.  #     
  105.  # "Igor::parseFuncs" --
  106.  #    
  107.  # This proc is called by the "{}" pop-up. It returns a dynamically
  108.  # created, alphabetical, list of "pseudo-marks".
  109.  #    
  110.  #    Author:    <jguyer@his.com>
  111.  # -------------------------------------------------------------------------
  112. proc Igor::parseFuncs {} {
  113.     global IgormodeVars
  114.     
  115.     set result {}
  116.     set pos [minPos]
  117.     
  118.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 $IgormodeVars(funcExpr) $pos} res]} {
  119.     set start [lindex $res 0]
  120.     set end [pos::math [lindex $res 1] + 1]
  121.     set text [getText $start $end]
  122. #     lappend result $text
  123.     set inds($text) [list $start [pos::math $start + [string length $text]]]
  124.     set pos $end
  125.     }
  126.     
  127.     set pos [minPos]
  128.     set markExpr {(^[ \t]*[Mm]enu.*$|===[^=]+===\s*$)}
  129.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 -- "$markExpr" $pos} res]} {
  130.     set start [lindex $res 0]
  131.     set end [pos::math [lindex $res 1] - 1]
  132.     set text [string trimright [getText $start $end] ]
  133. #     lappend result $text
  134.     set inds($text) [list $start [pos::math $start + [string length $text]]]
  135.     set pos $end
  136.     }
  137.     if {[info exists inds]} {
  138.     foreach f [array names inds] {
  139.         lappend result $f
  140. #         set res $inds($f)
  141. #         setNamedMark $f [lineStart [lindex $res 0]] [lindex $res 0] [lindex $res 1]
  142.     }
  143.     }
  144. #     namedMarkProc {namedMarks} {sortByPosition}
  145.     
  146.     return $result
  147. }
  148.  
  149.